#include "LuxSensor.h"

#include <charconv>

bool LuxSensor::updateInformation() {
    bool recheckResult = false;
    std::string result;
    try {
        mchannel.sendStringReturnString(std::string("<GET_LUX>"), result);
        if ("<GET_LUX_ERROR>" == result) {
            recheckResult = true;
        } else if (9 < result.size()){
            //std::from_chars(&result[9], &result[result.size()], lux,  std::chars_format::general);
            mluxString = result.substr(9, result.size() - 10);
      //      lux = std::strtod(result.data() + 9, nullptr);
        }

    } catch (std::exception& ex) {
        LOG_ERROR(ex.what());
    }
    return recheckResult;
}
